Skip to content

jextract/jni: Support optional tuple return values#720

Closed
sidepelican wants to merge 6 commits intoswiftlang:mainfrom
sidepelican:optional_tuple
Closed

jextract/jni: Support optional tuple return values#720
sidepelican wants to merge 6 commits intoswiftlang:mainfrom
sidepelican:optional_tuple

Conversation

@sidepelican
Copy link
Copy Markdown
Contributor

@sidepelican sidepelican commented Apr 23, 2026

Currently, code generation is skipped when an optional tuple is used as a return value.
This PR fixes this.

Support for optional tuples as parameters is currently out of scope.
Given the difficulty, I've decided to postpone this to a subsequent PR.

Architectural Concerns & Refactoring

During the implementation, I encountered a bottleneck where JNISwift2JavaGenerator+JavaTranslation.swift needed to reference results from JNISwift2JavaGenerator+NativeTranslation.swift.

The current architecture handles Java-side and Swift-side glue code generation independently.
This separation makes it increasingly difficult to keep the generation strategies in sync and ensure consistency between the two sides.

Future Work & Current Workaround

I believe unifying these generation logics will be essential in the future.
However, given the current scale of the implementation, such a major refactoring is extremely difficult at this stage.

As a result, this PR addresses the immediate issue using a workaround to bypass these structural limitations for now, while acknowledging the underlying architectural debt.

@sidepelican sidepelican requested a review from ktoso as a code owner April 23, 2026 02:45
@sidepelican
Copy link
Copy Markdown
Contributor Author

I understand the hesitation to merge this PR due to the workaround included.
I'll refine it further to make it more incrementally improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant